home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / networking / misc / sana2.lha / sana2 / examples / globstats / globstats.c next >
Encoding:
C/C++ Source or Header  |  1991-11-18  |  1.3 KB  |  62 lines

  1. /*
  2. **  $Id: globstats.c,v 1.4 91/11/13 11:18:52 dlarson Exp $
  3. **
  4. **  SANA-II driver utility -- Print statistics for device.
  5. **
  6. **  Copyright 1991 Commodore-Amiga, Inc.
  7. **
  8. **  This code may be modified and used freely on Amiga computers.
  9. **
  10. */
  11.  
  12.  
  13. #define NOBUFFS 1
  14. #include "/skeleton/skeleton.h"
  15.  
  16. struct MsgPort   *DevPort = NULL;
  17. struct IOSana2Req *IOB1    = NULL;
  18. struct Sana2DeviceStats Stats;
  19.  
  20. int    DeviceOpen = 0;
  21. long   DevBits;
  22.  
  23. void PrintStats(void);
  24. void GetGlobalStats(void);
  25.  
  26.  
  27. main(argc , argv)
  28. char *argv[];
  29. {
  30.     if(!initdev())
  31.         printf("Open Failed.\n");
  32.     else
  33.     {
  34.         GetGlobalStats();
  35.         if (!IOB1->ios2_Req.io_Error)
  36.             PrintStats();
  37.         else
  38.             printf("Error Returned: %ld WireError: %ld\n" , IOB1->ios2_Req.io_Error , IOB1->ios2_WireError);
  39.     }
  40. bottom:    closedev();
  41.     return(0);
  42. }
  43.  
  44. void GetGlobalStats(void)
  45. {
  46.     IOB1->ios2_Req.io_Error   = 0;
  47.     IOB1->ios2_Req.io_Flags   = IOF_QUICK;
  48.     IOB1->ios2_Req.io_Command = S2_GETGLOBALSTATS;
  49.     IOB1->ios2_StatData = &Stats;
  50.     DoIO(IOB1);
  51. }
  52.  
  53. void PrintStats(void)
  54. {
  55.     printf("Packets Received:    %d\n" , Stats.PacketsReceived);
  56.     printf("Packets Transmitted: %d\n" , Stats.PacketsSent);
  57.     printf("CRC Errors:          %d\n" , Stats.BadData);
  58.     printf("Unknown Packets:     %d\n" , Stats.UnknownTypesReceived);
  59.     printf("Fifo Overruns:       %d\n" , Stats.Overruns);
  60.     printf("Reconfigurations:    %d\n" , Stats.Reconfigurations);
  61. }
  62.